<?php
/**
 * Created by PhpStorm.
 * User: 六花
 * Date: 2019/8/15
 * Time: 16:34
 */

namespace Home\Controller;

class DescriptionController extends BaseMallController
{
    public function index(){
        if (!I('request.id')){
            render('10004','参数错误');
        }
        $res = M('goods')->where(array('goods_id'=>I('request.id')))
                ->field('description')
                ->find();
//        var_dump($res['description']);
        $res['description'] = str_replace('./','./../',$res['description']);
        //data-original
        $res['description'] = preg_replace('/<img(.*)src=\"(.*)\"(.*)\/>/iU','<img$1src="Public/home/img/default.jpg" data-original="$2"$3>',$res['description']);
        //
//        <p><img src="./data/files/store_2/goods_1/2019071014480282216633.jpeg"/>
//        <img src="./data/files/store_2/goods_1/2019071014480282425087.jpeg"/>
//        <img src="./data/files/store_2/goods_1/2019071014480383164680.jpeg"/>
//        <img src="./data/files/store_2/goods_1/2019071014480484970588.jpeg"/></p>
        $this->assign('description',$res['description']);
        $this->display();
    }

}